<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数</title>
    <style>
        #box {
            width: 200px;
            height: 200px;
            background-color: #0000af;
            font: bold 1px SansSerif;
            color: black;
        }
        #box1 {
            width: 200px;
            height: 200px;
            background-color: #eebb00;
            font: bold 1px SansSerif;
            color: black;
        }
    </style>
</head>
<body>
<div id="box" style="color: black;">这是js匿名函数操作属性</div>
<hr>
<div id="box1"></div>
<script>
    var box=document.getElementById('box');
    var box1=document.getElementById('box1');
    //匿名函数：
    // console.log(box);
    box.onclick=function () {
        box.style.width='400px';
        box.style.backgroundColor='#EEdddd';
    };
    box.onclick=function () {
      box['style']['background-color']='#EEEE00';
      box['style']['width']='400px';
      box['style']['font-size']='25px';
      box['style'].color='#EE8888';
      console.log(box.style.fontSize);  //行间属性需要在上面得div中加上style，才能获取到
    };

    //有名函数
    function fn() {
        box1.style['width']='600px';
        box1.style['font-size']='2em';
    }
    box1.onclick=fn;
</script>
</body>
</html>